package com.cty.advice;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.log4j.Logger;

/**
 * @Auther: cty
 * @Date: 2020/3/7 17:46
 * @Description:  环绕通知类
 * @version: 1.0
 */
public class MyAroundAdvice implements MethodInterceptor {
    // 获取日志对象
    Logger log = Logger.getLogger(MyAroundAdvice.class);

    /**
     *
     * @param methodInvocation  可以调用切点方法的对象
     * @return  返回切点方法的返回对象
     * @throws Throwable
     */
    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        log.debug("环绕前置通知-Schema-based");
        Object result = methodInvocation.proceed();  // 放行，调用切点方法
        log.debug("环绕后置通知-Schema-based");
        return result;
    }
}
